import request from '@/utils/request'

/**
 * 获取财务列表
 * @param {number} param.currPage 当前页
 * @param {number} param.pageSize 页容
 * @param {string} param.orderSn  订单编号
 * @param {string} param.nickname 用户名
*/
export function GetFinance(param) {
    let itemList = [];
    if (param.orderSn) {
        itemList.push({
            name: "order_sn",
            op: "like",
            value1: param.orderSn
        })
    }
    if (param.nickname) {
        itemList.push({
            name: "nickname",
            op: "like",
            value1: param.nickname
        })
    }
    return request({
        url: '/finance/query',
        method: 'post',
        data: {
            currPage: param.currPage,
            pageSize: param.pageSize,
            itemList,
        }
    })
}


/**
 * 删除财务数据
 * @param {number} id 记录id
*/
export function DeleteFinance(id) {
    return request({
        url: '/finance/delete',
        method: 'post',
        data: {
            id
        }
    })
}


/**
 * 获取体现审核记录
 * @param {string} param.cashOutStatus 状态
 * @param {string} param.nickname 名字
 */
export function GetWithdrawList(param) {
    return request({
        url: '/cashOut/queryCashOut',
        method: 'post',
        data: {
            currPage: param.currPage,
            pageSize: param.pageSize,
            itemList: [
                {
                    name: "cashOutStatus",
                    op: "eq",
                    value1: param.cashOutStatus
                },
                {
                    name: "nickname",
                    op: "like",
                    value1: param.nickname
                }
            ]
        }
    })

}

/**
 * 修改提现状态 
 * @param {string} param.cashOutStatus  提现申请状态  UNDER_REVIEW, ADOPT, REFUSE
 * @param {string} param.commissionAmount 金额
 * @param {number} param.id
 */
export function UpdateCashOutStatus(param, cashOutStatus) {
    return request({
        url: '/cashOut/updateStatus',
        method: 'post',
        data: {
            cashOutStatus,
            commissionAmount: param.commissionAmount,
            id: param.id
        }
    })

}

/**
 * 查看收入
 */
export function GetFindIncome() {
    return request({
        url: '/finance/findIncome',
        method: 'post'
    })
}